package com.mark.springbootvideo.controller.admin;

import com.mark.springbootvideo.entity.Video;
import com.mark.springbootvideo.service.VideoService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author: MARK
 * @Date: 2019/9/8 18:32
 * @Version: 1.0.0
 * @Description: 管理员操作api
 */
@RestController
@RequestMapping(value = "/admin/api/v1/video", produces = {"application/json;charset=UTF-8"})
public class VideoAdminController {

    @Resource
    private VideoService videoService;

    /**
     * @return void
     * @create: 2019/9/8
     * @author MARK
     * @param videoId
     * @Description: 根据id删除视频
     */
    @DeleteMapping("/del_by_id/{videoId}")
    public void delById(@PathVariable Integer videoId){
        videoService.delete(videoId);
    }

    /**
     * @return void
     * @create: 2019/9/8
     * @author MARK
     * @Description: 根据id更新视频
     */
    @PutMapping("/update")
    public void update(@RequestBody Video video){
        video.setId(video.getId());
        video.setTitle(video.getTitle());
        videoService.update(video);
    }

    /**
     * @return void
     * @create: 2019/9/8
     * @author MARK
     * @Description: 添加视频信息
     */
    @PostMapping("/insert")
    public void insert(@RequestBody Video video){
        videoService.save(video);
    }
}
